﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="jlparing1_vastus", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Jlparing1Vastus))]
    public class Jlparing1VastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJlparing1Vastus clazz;
        
        public Jlparing1VastusSerializer(IJlparing1Vastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Juht!=null) {
                Writer.WriteStartElement("juht");
                global::Xtee.Core.SerializationMetadata metaJuht = this.GetMetaData(clazz.Juht);
                Writer.WriteTypeAttribute(metaJuht.TypeQualifiedName.Namespace, metaJuht.TypeQualifiedName.Name);
                metaJuht.NewSerializer(clazz.Juht).WriteXml(Writer);
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "juht")) {
                goto juht;
            }
            else {
                return;
            }
        juht:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>jlparing1_vastus>juht");
            }
            global::Xtee.Core.SerializationMetadata metaJuht = this.GetMetaData<Jlparing1Vastus.IJuhtType>(Reader, ">>jlparing1_vastus>juht", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
            clazz.Juht = metaJuht.NewEntity<Jlparing1Vastus.IJuhtType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("juht");
                metaJuht.NewSerializer(clazz.Juht).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>jlparing1_vastus>juht", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Jlparing1Vastus.JuhtType))]
        public class JuhtTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected Jlparing1Vastus.IJuhtType clazz;
            
            public JuhtTypeSerializer(Jlparing1Vastus.IJuhtType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("eesnimi");
                if (clazz.Eesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("perekonnanimi");
                if (clazz.Perekonnanimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perekonnanimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Perekonnanimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("synniaeg");
                if (clazz.Synniaeg!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synniaeg))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Synniaeg");
                }
                Writer.WriteEndElement();
                if (clazz.Isikukood!=null) {
                    Writer.WriteStartElement("isikukood");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                    Writer.WriteEndElement();
                }
                Writer.WriteStartElement("synnikoha_riik");
                if (clazz.SynnikohaRiik!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SynnikohaRiik))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SynnikohaRiik");
                }
                Writer.WriteEndElement();
                if (clazz.Haldusyksus!=null) {
                    Writer.WriteStartElement("haldusyksus");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Haldusyksus))).ToString());
                    Writer.WriteEndElement();
                }
                if (clazz.Aadress!=null) {
                    Writer.WriteStartElement("aadress");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                    Writer.WriteEndElement();
                }
                Writer.WriteStartElement("juhiload");
                if (clazz.Juhiload!=null) {
                    global::Xtee.Core.SerializationMetadata metaJuhiload = this.GetMetaData(clazz.Juhiload);
                    Writer.WriteTypeAttribute(metaJuhiload.TypeQualifiedName.Namespace, metaJuhiload.TypeQualifiedName.Name);
                    metaJuhiload.NewSerializer(clazz.Juhiload).WriteXml(Writer);
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Juhiload");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
            START:
                if ((Reader.LocalName == "eesnimi")) {
                    goto eesnimi;
                }
                else {
                    if ((Reader.LocalName == "perekonnanimi")) {
                        goto perekonnanimi;
                    }
                    else {
                        if ((Reader.LocalName == "synniaeg")) {
                            goto synniaeg;
                        }
                        else {
                            if ((Reader.LocalName == "isikukood")) {
                                goto isikukood;
                            }
                            else {
                                if ((Reader.LocalName == "synnikoha_riik")) {
                                    goto synnikoha_riik;
                                }
                                else {
                                    if ((Reader.LocalName == "haldusyksus")) {
                                        goto haldusyksus;
                                    }
                                    else {
                                        if ((Reader.LocalName == "aadress")) {
                                            goto aadress;
                                        }
                                        else {
                                            if ((Reader.LocalName == "juhiload")) {
                                                goto juhiload;
                                            }
                                            else {
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            eesnimi:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
                goto START;
            perekonnanimi:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>perekonnanimi");
                }
                clazz.Perekonnanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perekonnanimi")).Value;
                goto START;
            synniaeg:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>synniaeg");
                }
                clazz.Synniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synniaeg")).Value;
                goto START;
            isikukood:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
                goto START;
            synnikoha_riik:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>synnikoha_riik");
                }
                clazz.SynnikohaRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synnikoha_riik")).Value;
                goto START;
            haldusyksus:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>haldusyksus");
                }
                clazz.Haldusyksus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("haldusyksus")).Value;
                goto START;
            aadress:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>aadress");
                }
                clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
                goto START;
            juhiload:
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>jlparing1_vastus>juht>juhiload");
                }
                global::Xtee.Core.SerializationMetadata metaJuhiload = this.GetMetaData<Jlparing1Vastus.JuhtType.IJuhiloadType>(Reader, ">>>jlparing1_vastus>juht>juhiload", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
                clazz.Juhiload = metaJuhiload.NewEntity<Jlparing1Vastus.JuhtType.IJuhiloadType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("juhiload");
                    metaJuhiload.NewSerializer(clazz.Juhiload).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
                goto START;
            }
            
            [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>jlparing1_vastus>juht>juhiload", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Jlparing1Vastus.JuhtType.JuhiloadType))]
            public class JuhiloadTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
                
                protected Jlparing1Vastus.JuhtType.IJuhiloadType clazz;
                
                public JuhiloadTypeSerializer(Jlparing1Vastus.JuhtType.IJuhiloadType clazz) {
                    this.clazz = clazz;
                }
                
                public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                    base.WriteXml(Writer);
                    for (int x = 0; ((clazz.Item != null) 
                                && (x < clazz.Item.Count)); x = (x + 1)) {
                        if (clazz.Item[x]!=null) {
                            Writer.WriteStartElement("item");
                            global::Xtee.Core.SerializationMetadata metaItem = this.GetMetaData(clazz.Item[x]);
                            Writer.WriteTypeAttribute(metaItem.TypeQualifiedName.Namespace, metaItem.TypeQualifiedName.Name);
                            metaItem.NewSerializer(clazz.Item[x]).WriteXml(Writer);
                            Writer.WriteEndElement();
                        }
                    }
                }
                
                public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                    base.ReadXml(Reader);
                    if (Reader.LocalName=="item") {
                        clazz.Item = new System.Collections.Generic.List<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload>();
                        for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                    && (Reader.LocalName == "item")); ) {
                            if (Reader.IsElementNil()) {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>jlparing1_vastus>juht>juhiload>item");
                            }
                            global::Xtee.Core.SerializationMetadata metaItem = this.GetMetaData<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload>(Reader, "juhiload", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
                            global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload item = metaItem.NewEntity<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload>();
                            clazz.Item.Add(item);
                            if ((Reader.IsEmptyElement == false)) {
                                Reader.ReadStartElement("item");
                                metaItem.NewSerializer(item).ReadXml(Reader);
                                Reader.ReadEndElement();
                            }
                            else {
                                Reader.Skip();
                            }
                        }
                    }
                }
            }
        }
    }
}
